<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/bootstrap-3.3.7-dist/css/bootstrap.css">
    <title>修改图书</title>
</head>
<body>
<div class="container-fluid">
    <div class="row">

        <div class="col-md-6 col-md-offset-3">
            <h1>新增图书</h1>
            <hr>
            <form action="/book_update/{{ book.pk }}" method="post" enctype="">

                <div class="form-group">
                    <p>书名: <input type="text" name="name" class="form-control" value="{{ book.name }}"></p>
                </div>
                <div class="form-group">
                    <p>价格: <input type="text" name="price" class="form-control" value="{{ book.price }}"></p>
                </div>
                <div class="form-group">
                    <p>出版日期: <input type="date" name="pub_date" class="form-control"
                                    value="{{ book.pub_date|date:'Y-m-d' }}"></p>
                </div>
                <div class="form-group">
                    <p>作者:
                        <select name="authors" class="form-control" multiple>
                            {% for author in authors %}
                                {% if author in book.authors.all %}
                                    <option value="{{ author.id }}" selected>{{ author.name }}</option>
                                {% else %}
                                    <option value="{{ author.id }}">{{ author.name }}</option>
                                {% endif %}

                            {% endfor %}
                        </select>
                    </p>
                </div>
                <div class="form-group">
                    <p>出版社: <select name="publish" class="form-control">
                        {% for publish in publish_list %}
                            {% if publish == book.publish %}
                                <option value="{{ publish.id }}" selected>{{ publish.name }}</option>
                            {% else %}
                                <option value="{{ publish.id }}">{{ publish.name }}</option>
                            {% endif %}

                        {% endfor %}
                    </select>
                    </p>
                </div>

                <input type="submit" value="提交" class="btn btn-primary">
            </form>

        </div>
    </div>
</div>
</body>
</html>